﻿app.factory('NoteFactory', ['$http', '$q', function ($http, $q) {
    var o = {
        notes: []
    };
    o.getNotes = function () {
        var q = $q.defer();
        $http({
            url: '/api/apiNotes',
            method: 'GET',
            headers: { Authorization: 'Bearer ' + localStorage.getItem('token') }
        }).success(function (data) {
            o.notes.length = 0;
            for (var i = 0; i < data.length; i++) {
                o.notes[i] = data[i];
            }
            console.log(o.notes);
        }).error(function (data) {
        });
        return q.promise;
    }
    return o;
}]);